﻿// Sheego.Service.X400
// Copyright(C) 2015 Schwab Versand GmbH
//
// This source file is subject to the Microsoft Public License(Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Sheego.Service.X400.Job.Impl.BO;
using Sheego.Service.X400.Job.Impl.Comparer;
using Sheego.Service.X400.Job.Impl.Matcher;
using Sheego.Service.X400.Job.Impl.Parser;
using Sheego.Service.X400.Job.Impl.Processor;
using Sheego.Service.X400.Job.Shared;
using Sheego.Service.X400.Job.Shared.BO;
using Sheego.Service.X400.Job.Shared.Comparer;
using Sheego.Service.X400.Job.Shared.Matcher;
using Sheego.Service.X400.Job.Shared.Parser;
using Sheego.Service.X400.Job.Shared.Processor;
using Sheego.Service.X400.Scheduler.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sheego.Service.X400.Job.Impl.Locator
{
    public class JobInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component.For<IJob>().ImplementedBy<X400Job>().LifestyleSingleton());
            container.Register(Component.For<IJobLogger>().ImplementedBy<JobLogger>().LifestyleSingleton());

            container.Register(Component.For<IFileManager>().ImplementedBy<FileManager>().LifestyleSingleton());

            container.Register(Component.For<IUAFIProcess>().ImplementedBy<UAFIProcess>().LifestyleSingleton());


            container.Register(Component.For<IUAFICommandFactory>().ImplementedBy<UAFICommandFactory>().LifestyleSingleton());
            container.Register(Component.For<IUAFICommand>().ImplementedBy<UAFICommand>().LifestyleTransient());
            container.Register(Component.For<IUAFIResponseParser>().ImplementedBy<UAFIResponseParser>().LifestyleSingleton());
            container.Register(Component.For<IUAFIResponse>().ImplementedBy<UAFIResponse>().LifestyleTransient());

            container.Register(Component.For<IX400MessageRouter>().ImplementedBy<X400MessageRouter>().LifestyleSingleton()); //Kein Singleton
            container.Register(Component.For<IX400MessageParser>().ImplementedBy<X400MessageParser>().LifestyleSingleton());
            container.Register(Component.For<IX400AddressParser>().ImplementedBy<X400AddressParser>().LifestyleSingleton());
            container.Register(Component.For<IX400MessageCache>().ImplementedBy<X400MessageCache>().LifestyleSingleton());

            container.Register(Component.For<IEDIFACTParser>().ImplementedBy<EDIFACTParser>().LifestyleSingleton());
            container.Register(Component.For<IEDIFACTParserStream>().ImplementedBy<EDIFACTParserStream>().LifestyleTransient());


            container.Register(Component.For<IContentType>().ImplementedBy<ContentType>().LifestyleTransient());
            container.Register(Component.For<IX400Message>().ImplementedBy<X400Message>().LifestyleTransient());
            container.Register(Component.For<IX400MessagePart>().ImplementedBy<X400MessagePart>().LifestyleTransient());
            container.Register(Component.For<IX400Address>().ImplementedBy<X400Address>().LifestyleTransient());
            container.Register(Component.For<IX400MessageRule>().ImplementedBy<X400MessageRule>().LifestyleTransient());

            container.Register(Component.For<IConsoleProcess>().ImplementedBy<ConsoleProcess>().LifestyleTransient());


            container.Register(Component.For<IX400MessageProcessor>().ImplementedBy<CopyEDIFACTMessageProcessor>().Named(ProcessorType.CopyEDIFACT).LifestyleTransient());
            container.Register(Component.For<IX400MessageProcessor>().ImplementedBy<ArchiveMessageProcessor>().Named(ProcessorType.Archive).LifestyleTransient());
            container.Register(Component.For<IX400MessageProcessor>().ImplementedBy<SendMailProcessor>().Named(ProcessorType.SendMail).LifestyleTransient());

            container.Register(Component.For<IX400MessageMatcher>().ImplementedBy<StaticMatcher>().Named(MatcherType.Static).LifestyleTransient());
            container.Register(Component.For<IX400MessageMatcher>().ImplementedBy<X400AddressMatcher>().Named(MatcherType.Address).LifestyleTransient());

            container.Register(Component.For<IX400AddressComparer>().ImplementedBy<X400AddressComparer>().LifestyleSingleton());

            container.Register(Component.For<IXmlWrapper>().ImplementedBy<XmlWrapper>().LifestyleTransient()); //Wichtig
            container.Register(Component.For<IJobConfiguration>().ImplementedBy<ConfigurationAdapter>().LifestyleSingleton());
            container.Register(Component.For<IJobRuleConfiguration>().ImplementedBy<RuleConfigurationAdapter>().LifestyleSingleton());

            container.Register(Component.For<IMailManager>().ImplementedBy<MailManager>().LifestyleSingleton());
            container.Register(Component.For<IMailMessage>().ImplementedBy<MailMessage>().LifestyleTransient());
            container.Register(Component.For<IMailAttachment>().ImplementedBy<MailAttachment>().LifestyleTransient());
            
            container.Register(Component.For<IRange>().ImplementedBy<Range>().LifestyleTransient());
            container.Register(Component.For<IRangeParser>().ImplementedBy<RangeParser>().LifestyleSingleton()); 

        }
    }

}
